﻿@using CodeGenerator.Common
@using CodeGenerator.Core
@using System.Text
@{
    MybatisCodeCreate model = Model;
    string entityName = Utils.Pascal(model.Name);
    string whereStr = "";
    string whereParamStr = "";
    string daoVariable = Utils.Camel(model.Name)+"Dao";
    for (int i = 1; i <= model.TableInfo.PrimaryKeyColumns.Count; i++)
    {
        ColumnInfo column = model.TableInfo.PrimaryKeyColumns[i - 1];

        if (i != model.TableInfo.PrimaryKeyColumns.Count)
        {
            whereStr += column.JavaType.Alias + " " + column.Name + "" + " , ";
            whereParamStr += column.Name+" , ";
        }
        else
        {
            whereStr += column.JavaType.Alias + " " + column.Name + "";
            whereParamStr += column.Name + "";
        }
    }
}
package @(model.ServicePackage);

import @(model.DaoPackage);
import @(model.IServicePackage);
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@@Service
public class @(entityName)ServiceImpl implements @(entityName)Service {
    @@Autowired
    private @(entityName)Dao @(daoVariable);
    
   
    @@Override
    public int deleteByPrimaryKey(@whereStr) {
        return @(daoVariable).deleteByPrimaryKey(@whereParamStr);
    }

    @@Override
    public int insert(@(entityName) record) {
        return @(daoVariable).insert(record);
    }

    @@Override
    public int insertSelective(@(entityName) record) {
        return @(daoVariable).insertSelective(record);
    }

    @@Override
    public @(entityName) selectByPrimary(@whereStr) {
        return @(daoVariable).selectByPrimary(@whereParamStr);
    }

    @@Override
    public int updateByPrimaryKeySelective(@(entityName) record) {
        return @(daoVariable).updateByPrimaryKeySelective(record);
    }

    @@Override
    public int updateByPrimaryKey(@(entityName) record) {
        return @(daoVariable).updateByPrimaryKey(record);
    }

    @@Override
    public List<@(entityName)> selectList(@(entityName) record)
    {
        return @(daoVariable).selectList(record);
    }
}
